package com.yt.phone;

import com.qfjg.webcore.auth.Pass;
import com.qfjg.webcore.auth.TokenParam;
import com.qfjg.webcore.auth.Tokens;
import com.qfjg.webcore.log.ActionLog;
import com.qfjg.webcore.log.ActionLogBehavior;
import com.yt.phone.nanhaiju.NhSmsService;
import com.yt.phone.nanhaiju.SmsInfo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;

@Tag(name = "phone", description = "短信服务")
@RestController
@RequestMapping("/${spring.application.name}/phone")
public class PhoneController {
    private SmsService smsService;
    public PhoneController(SmsService smsService){
        this.smsService=smsService;
    }

    @Operation(summary = "发送验证码")
    @PostMapping("/sendSmsCode")
    @ActionLog(LOG_BEHAVIOR = ActionLogBehavior.Both)
    @Tokens(must_token = TokenParam.It)
    public void sendSmsCode(@RequestBody SmsCodeInfo smsCodeInfo) throws Exception {
         smsService.sendSmsCode(smsCodeInfo.getPhoneNum(),smsCodeInfo.getCode());
    }
    @Operation(summary = "发送短信")
    @PostMapping("/sendSmsText")
    @ActionLog(LOG_BEHAVIOR = ActionLogBehavior.Both)
    @Pass
    public void sendSmsText(@RequestBody SmsTextInfo smsTextInfo) throws Exception {
        smsService.sendSmsText(smsTextInfo.getPhoneNum(),smsTextInfo.getText());
    }

}
